#!/bin/bash
DELETECOUNT=`svn status   | grep ".bak"  |wc -l`
if [ $DELETECOUNT = "0" ]
then
    until [ $DELETECOUNT -lt "0" ]
    do
        DELETE=` svn status  | grep ".bak" | awk {'print $2'} | head -$DELETECOUNT | tail -1 `
        rm -rf $DELETE
        DELETECOUNT=`expr $DELETECOUNT - 1 `
    done
fi

COUNT=`svn status   | grep '^?.*\.cpp$'  |wc -l`
until [ $COUNT -lt "1" ]
do
    CURRENT=`svn status  | grep '^?.*\.cpp$' |awk {'print $2'} | head -$COUNT | tail -1`
    echo "Do you want to add $CURRENT? (y/n): "
    read ANS
    if [ $ANS = "y" ]
    then
        svn add $CURRENT
        echo "$CURRENT added to repository"
        COUNT=`expr $COUNT - 1 `
    elif [ $ANS = "n" ]
    then
        COUNT=`expr $COUNT - 1 `
    fi
done

COUNT=`svn status   | grep '^?.*\.h$'  |wc -l`
until [ $COUNT -lt "1" ]
do
    CURRENT=`svn status  | grep '^?.*\.h$' |awk {'print $2'} | head -$COUNT | tail -1`
    echo "Do you want to add $CURRENT? (y/n): "
    read ANS
    if [ $ANS = "y" ]
    then
        svn add $CURRENT
        echo "$CURRENT added to repository"
        COUNT=`expr $COUNT - 1 `
    elif [ $ANS = "n" ]
    then
        COUNT=`expr $COUNT - 1 `
    fi
done

echo "Enter a commit message: "
read MSG
svn commit -m "$MSG"
